<template>
  <div class="page-article" v-if="model">
    <div class="d-flex py-3 px-2 border-bottom">
      <div class="iconfont icon-back text-blue"></div>
      <strong class="flex-1 text-blue pl-2">
        {{model.title}}
      </strong>
      <div class="text-grey fs-xs">
        2019-06-19
      </div>
    </div>
    <div v-html="model.body" class="px-3 fs-lg body"></div>
  </div>
</template>

<script>
export default {
  // 接收由路由映射过来的参数id
  props: {
    id: {require: true}
  },
  data(){
    return {
      model:null,
    }
  },
  created(){
    this.fetch()
  },
  methods:{
    async fetch() {
      const res = await this.$http.get(`articles/${this.id}`)
      this.model = res.data
    }
  },
}
</script>

<style lang="scss">
  .page-article {
    .icon-back {
      font-size: 1.6923rem;
    }
    .body {
      img {
        max-width: 100%;
        height: auto;
      }

      iframe {
        width: 100%;
        height: auto;
      }
    }
  }
</style>
